local linfeng = fk.CreateSkill{
    name = "XD__linfeng",
}
Fk:loadTranslationTable{
    ["XD__linfeng"] = "临锋",
    [":XD__linfeng"] = "回合技，当其他角色使用【杀】指定目标时，你可以摸一张牌（若你的体力不大于2则改为摸两张牌），视为其对你使用一张【决斗】（不可被【无懈可击】响应），若你以此法对其造成伤害，该【杀】无效。",
    ["#XD__linfeng"] = "临锋：是否摸%arg张牌，视为%dest对你使用【决斗】，以尝试无效%arg2",
}

local U = require "packages/utility/utility"

linfeng:addEffect(fk.TargetSpecifying, {
    anim_type = "drawcard",
    can_trigger = function (self, event, target, player, data)
        return target ~= player and player:hasSkill(linfeng.name) and player:usedSkillTimes(linfeng.name, Player.HistoryTurn) < 1 and data.card.trueName == "slash"
    end,
    on_cost = function (self, event, target, player, data)
        local num = 1
        if player.hp < 3 then num = 2 end
        if player.room:askToSkillInvoke(player, {
            skill_name = linfeng.name,
            prompt = "#XD__linfeng::"..target.id..":"..U.ConvertNumber(num)..":"..data.card:toLogString()
        }) then
            return true
        end
    end,
    on_use = function (self, event, target, player, data)
        local room = player.room
        local num = 1
        if player.hp < 3 then num = 2 end
        player:drawCards(num, linfeng.name)
        local card = Fk:cloneCard("duel")
        card.skillName = linfeng.name
        if not player.dead and not target.dead and target:canUseTo(card , player) then
            local use = room:useVirtualCard("duel",nil,target,{player},linfeng.name)
            if use.damageDealt and use.damageDealt[target] then
                data:setNullified(data:getAllTargets())
            end
        end
    end,
})

linfeng:addEffect(fk.PreCardUse, {
    can_refresh = function (self, event, target, player, data)
        return data.card.skillName == linfeng.name
    end,
    on_refresh = function (self, event, target, player, data)
        data.prohibitedCardNames = data.prohibitedCardNames or {}
        table.insertIfNeed(data.prohibitedCardNames, "nullification")
    end,
})

return linfeng